define([
    'angular',
    'config',
    'constants'
],function(angular,config, constants) {
    angular.module('gold.products',[])

        .factory('$$products',['$http','$timeout','$q',
            function($http,$timeout,$q) {

             return{
                 // 邮件发送接口
                 sendEmail:function (keywords,options) {
                     $http({
                         method: 'POST',
                         dataType: "json",
                         contentType:'application/json; charset=UTF-8',
                         url: config.backend.ip + config.backend.pack,
                         headers: {},
                         data:{
                             head:{
                                 "transCode":"OrderApply",
                                 "transType":"Req",
                                 "token":$$user.getUser().token
                             },
                             "contractNo":pack.contractNo,
                             "paymentType":pack.paymentType,
                             "poaCode":pack.poaCode || '',
                             "operatorCode":$$user.getUser().userCode,
                             "loginCom":$$user.getUser().comCode
                         }
                     })
                         .success(function(data){
                             if(data){
                                 if(data && options.onSuccess)
                                     options.onSuccess(data);
                             }else{
                                 options.onError(data);
                             }
                         })
                         .error(function(e, code){
                             options.onError(code);
                         });
                 }
             }
            }])
});